#!/usr/bin/env python3
import sys

# sliding window of input line elements
class Window:
    def __init__(self):
        self.window = [ None, None, None ]

    def slide(self):
        for i in range(len(self.window) - 1):
            self.window[i] = self.window[i + 1]
        print(self.window)

    def analyze(self):
        if not self.window[1]: return
        for i in range(len(self.window[1])):
            up = self.window[0][i] if self.window[0] else sys.maxsize
            left = sys.maxsize if i == 0 else self.window[1][i - 1]
            middle = self.window[1][i]
            right = sys.maxsize if i == len(self.window[1]) - 1 else self.window[1][i + 1]
            down = self.window[2][i]
            if smaller(middle, [up, left, right, down]):
                yield middle + 1

    def process(self, elements):
        self.window[len(self.window) - 1] = elements

def smaller(a, elements):
    for b in elements:
        if b <= a:
            return False
    return True

def collect(generator):
    return sum([ e for e in generator ])

total = 0
window = Window()
for line in sys.stdin:
    window.slide()
    window.process(list(map(int, line.rstrip('\n'))))
    #for e in window.analyze(): print(e)
    total += collect(window.analyze())
# very ugly to have to repeat loop body
window.slide()
window.process([ 1 + e for e in window.window[2]])
total += collect(window.analyze())

print(f'sum of risk levels of all low points is {total}')
